package com.yiwu.common.exception;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.yiwu.common.enums.ResponseCode;
import lombok.Data;

import java.io.Serializable;

/**
 * @version 1.0
 * @description TODO
 * @date 2024/5/15 1:15
 */
@Data
public class BaseResponse<T> implements Serializable {
    private final int code;
    private final String message;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private T data;

    public BaseResponse(int code, String msg, T data) {
        this.code = code;
        this.message = msg;
        this.data = data;
    }

    public BaseResponse(int code,String msg) {
        this.code = code;
        this.message =  msg;
    }

    public BaseResponse(ResponseCode code) {
        this.code = code.getCode();
        this.message =  code.getMessage();
    }
}
